package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.system.IMEConversionMode;
	
	/**
	 * ...
	 * @author Lorenzo Nuvoletta
	 */
	public class Main extends Sprite 
	{
		public namespace Lorenzo;
		public namespace Anthony;
		public namespace Adam;
		
		public var _ns:Namespace = Lorenzo;
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			addEventListener(Event.ENTER_FRAME, _ns::render);
		}
		
		private function _increment():void
		{
			_numRenders++;
		}
		
		private var _numRenders:int = 0;
		Lorenzo function render(e:Event):void
		{
			trace("rendering Lorenzo's way");
			_increment();
			if (_numRenders % 39 == 0)
			{
				_ns = Anthony;
				removeEventListener(Event.ENTER_FRAME, _ns::render);
				addEventListener(Event.ENTER_FRAME, _ns::render);
			}
		}
		
		Anthony function render(e:Event):void
		{
			trace("rendering Anthony's way");
			_increment();
			if (_numRenders % 29 == 0)
			{
				_ns = Adam;
				removeEventListener(Event.ENTER_FRAME, _ns::render);
				addEventListener(Event.ENTER_FRAME, _ns::render);
			}
		}
		
		Adam function render(e:Event):void
		{
			trace("rendering Adam's way");
			_increment();
			if (_numRenders % 19 == 0)
			{
				_ns = Lorenzo;
				removeEventListener(Event.ENTER_FRAME, _ns::render);
				addEventListener(Event.ENTER_FRAME, _ns::render);
			}
		}
		
		
	}
	
}